class EditionCredit < ActiveRecord::Base
  #Relations
  belongs_to	:artist
  belongs_to	:edition

  #Callbacks
  after_create :new_entry_edit
  after_update :create_edit

  #Validations
  validates_associated :artist
  validates_associated :edition  

  #Constants
  ROLES = %w(Performance Composed Engineered Mixed Produced Featuring Remixed)
  
  private

  #
  #
  def new_entry_edit
      entry = Hash.new
      entry.store("created credit", [artist.to_s, edition.to_s])
      Edit.create_edit(entry, artist)
  end

  #
  #
  def create_edit
    if self.changed?
      puts changes
      Edit.create_edit(self.changes, artist)
    end
  end
  
end
